﻿using System;
using System.Web.Mvc;
using Downloader.Domain;
using Downloader.Domain.Contracts.Tasks;
using Downloader.Web.Controllers.Queries;
using SharpArch.NHibernate.Web.Mvc;

namespace Downloader.Web.Controllers.Admin
{
    public class WebSiteInfoController : Controller
    {
        public IWebSiteInfoQuery WebSiteInfoQuery { get; set; }
       public IWebSiteInfoTasks WebSiteInfoTasks { get; set; }
        public WebSiteInfoController()
        {
          
        }
        //
        // GET: /WebSiteInfo/
        public ActionResult Index()
        {
            var webinfo = WebSiteInfoQuery.GetWebInfo();
            return View(webinfo);
        }

        [Transaction]
        [ValidateInput(false)]
        public ActionResult SaveOrUpdate(WebSiteInfo webSiteInfo)
        {

            try
            {
                WebSiteInfoTasks.CreateOrUpdate(webSiteInfo);
            }
            catch (Exception exc)
            {
                return Json(new { success = false, data = exc.Message });
            }
            return Json(new { success = true });
        }

    }
}
